//
//  SWListButton.m
//  fishGame
//
//  Created by Charles How on 12-4-16.
//  Copyright 2012年 hust. All rights reserved.
//

#import "SWListButton.h"

#import "SW_ITEM.h"
#import "SWList.h"
#import "SWListLayer.h"

#import "GameMusicSetting.h"

@implementation SWListButton

#pragma mark goto list sw



+(void)gotoSWList:(id)sender
{
    ///数据获取线程还未结束，则不能进入
    SWList * aSWList=[SWList sharedInstance];
    if ([aSWList getThreadOverFlag] == false) {
        myNSLog(@"aSWList getThreadOverFlag false\n");
        return;
    }
    
    
    [GameMusicSetting playButtonClickEffect];
    
    
    
    
    ///push scene,pop scene
	CCScene *scene = [CCScene node];
	
	SWListLayer *layer = [SWListLayer node];
    [layer setPageIndex:0];
    [layer updateDisplay];
	[scene addChild:layer z:1];
	
	//[[CCDirector sharedDirector] runWithScene: [HelloWorld scene]];
	[[CCDirector sharedDirector] pushScene:scene];
}

+(void)addSWListButton:(id)sender point:(CGPoint)position
{
	CCSprite * tmp=[CCSprite spriteWithFile:@"sw-list-menu-button.png"];
	
	CGSize size = [[CCDirector sharedDirector] winSize];
    
	
    
	CCMenuItemImage * help=[CCMenuItemImage itemFromNormalImage:@"sw-list-menu-button.png" 
												  selectedImage:@"sw-list-menu-button.png" 
														 target:self selector:@selector(gotoSWList:)];
	
    /*
     tmp.scale=36/(float)tmp.contentSize.width;
     CCMenuItemSprite * help=[CCMenuItemSprite itemFromNormalSprite:(CCNode<CCRGBAProtocol>*)tmp selectedSprite:(CCNode<CCRGBAProtocol>*)tmp 
     target:self selector:@selector(gotoGameCenter:)];
     */
	CCMenu * menu=[CCMenu menuWithItems:help,nil];
	//menu.position=ccp(tmp.contentSize.width/2,tmp.contentSize.height/6-2);
    CGPoint newPoint=ccp(position.x+tmp.contentSize.width/2, position.y);
    //menu.anchorPoint=ccp(0.0, 0.0);  //左下角定位
    menu.position=position;
    
	//[self addChild:menu z:4];
	[sender addChild:menu z:10];	
}


@end
